import React from 'react';
import {Card, Form, Input, InputNumber,Switch} from "antd";
import {Link} from "react-router-dom";
import {SecurityMenu} from "type/SecurityMenu";
import TextArea from "antd/es/input/TextArea";
import LogFactory from "log/LogFactory";
import {fetchAddData} from "../../../redux/reducer/menuReducer" ;

import FormEnhance from "common/form/FormEnhance";
import SelectEnhance from "common/select/SelectEnhance";

const log = LogFactory.getLog("MenuAddComponent");
const MenuAddComponent = () => {
    const [form] = Form.useForm<SecurityMenu>() ;
    return (
        <Card
            title={"添加菜单"}
            extra={<Link to={""}>菜单列表</Link>}
        >
                <FormEnhance<SecurityMenu>
                    submitText={"添加"}
                    fetchAddData = {fetchAddData}
                    initialValues={{
                        order: 1,
                        menuOrder: 1,
                        path: '/',
                        parentId: 1300000000
                    }}
                    form={form}
                >
                    <SelectEnhance<SecurityMenu> form={form} rowKey={'path'} selectLabel={"父菜单"} selectName={"parentId"}/>
                    <Form.Item<SecurityMenu> label="菜单路径" name={"path"}>
                        <Input />
                    </Form.Item>
                    <Form.Item<SecurityMenu> label="菜单标题" name={"label"}>
                        <Input />
                    </Form.Item>
                    <Form.Item<SecurityMenu> label="功能描述" name={"describe"}>
                        <Input />
                    </Form.Item>
                    <Form.Item<SecurityMenu> label="菜单图标" name={"icon"}>
                        <Input />
                    </Form.Item>
                    <Form.Item<SecurityMenu> label="子菜单" name={"last"}>
                        <Switch />
                    </Form.Item>
                    <Form.Item<SecurityMenu> label="是否显示" name={"show"}>
                        <Switch />
                    </Form.Item>
                    <Form.Item<SecurityMenu> name={"menuOrder"} label="菜单排序">
                        <InputNumber min={0}/>
                    </Form.Item>
                    <Form.Item<SecurityMenu> name={"order"} label="数据排序">
                        <InputNumber min={0}/>
                    </Form.Item>
                    <Form.Item<SecurityMenu> name={"remark"} label="备注信息">
                        <TextArea rows={5}/>
                    </Form.Item>
                </FormEnhance>
        </Card>
    );
};

export default MenuAddComponent;